---
title: Server-side clients
sidebar:
  order: 20
---

import { Tabs, TabItem } from '@astrojs/starlight/components';

import MainSnippet from '../../_assets/code/reference/syncing/server-side-clients/main.ts?snippet'
import SchemaSnippet from '../../_assets/code/reference/syncing/server-side-clients/schema.ts?snippet'
import ServerSideClientDiagram from '../../_assets/diagrams/server-side-client.tldr?tldraw';

You can also use LiveStore on the server side e.g. via the `@livestore/adapter-node` adapter. This allows you to:
- have an up-to-date server-side SQLite database (read model)
- react to events / state changes on the server side (e.g. to send emails/push notifications)
- commit events on the server side (e.g. for sensitive/trusted operations)

<ServerSideClientDiagram />

Note about the schema: While the `events` schema needs to be shared across all clients, the `state` schema can be different for each client (e.g. to allow for a different SQLite table design on the server side).

## Example

<Tabs>
  <TabItem label="main.ts">
    <MainSnippet />
  </TabItem>
  <TabItem label="schema.ts">
    <SchemaSnippet />
  </TabItem>
</Tabs>

## Further notes

### Cloudflare Workers

- The `@livestore/adapter-node` adapter doesn't yet work with Cloudflare Workers but you can follow [this issue](https://github.com/livestorejs/livestore/issues/266) for a Cloudflare adapter to enable this use case.
- Having a `@livestore/adapter-cf-worker` adapter could enable serverless server-side client scenarios.
